import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        // 输入n, m, q
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int q = scanner.nextInt();

        // 初始化二维数组a和sum
        long[][] a = new long[n + 1][m + 1];  // 使用n+1行，m+1列的二维数组
        long[][] sum = new long[n + 1][m + 1];  // 前缀和数组

        // 输入二维数组a，并计算前缀和sum
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                a[i][j] = scanner.nextLong();  // 输入a[i][j]
                sum[i][j] = sum[i][j - 1] + a[i][j];  // 一维前缀和处理
            }
            for (int j = 1; j <= m; j++) {
                sum[i][j] += sum[i - 1][j];  // 二维前缀和处理
            }
        }

        // 处理q次查询
        for (int i = 0; i < q; i++) {
            int x1 = scanner.nextInt();
            int y1 = scanner.nextInt();
            int x2 = scanner.nextInt();
            int y2 = scanner.nextInt();
            System.out.println(getSum(x1, y1, x2, y2, sum));  // 输出结果
        }

        scanner.close();
    }

    // 计算二维前缀和矩形区域的和
    public static long getSum(int x1, int y1, int x2, int y2, long[][] sum) {
        if (x1 > x2 || y1 > y2) return 0;  // 越界处理
        return sum[x2][y2] - sum[x1 - 1][y2] - sum[x2][y1 - 1] + sum[x1 - 1][y1 - 1];  // 计算矩形区域的和
    }

}
